<?php

/**
 * This is the model class for table "assessment_member".
 *
 * The followings are the available columns in table 'assessment_member':
 * @property integer $ASSMNT_MBR_ID
 * @property string $EMPLOYEE_ID
 * @property string $ASSESSOR_EMPLOYEE_ID
 * @property integer $ASSESSMENT_TYPE
 * @property integer $ASSESSMENT_ID
 * @property integer $JOB_TITLE_ID
 * @property integer $USER_CREATED
 * @property string $TIME_CREATED
 * @property integer $USER_UPDATED
 * @property string $TIME_UPDATED
 *
 * The followings are the available model relations:
 * @property CompetencyContent[] $competencyContents
 * @property Assessment $aSSESSMENT
 * @property Employee $eMPLOYEE
 * @property Employee $aSSESSOREMPLOYEE
 * @property JobTitle $jOBTITLE
 */
class AssessmentMember extends CMasterModel
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return AssessmentMember the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'assessment_member';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ASSESSMENT_TYPE, ASSESSMENT_ID, JOB_TITLE_ID', 'required'),
			array('ASSESSMENT_TYPE, ASSESSMENT_ID, JOB_TITLE_ID, USER_CREATED, USER_UPDATED', 'numerical', 'integerOnly'=>true),
			array('EMPLOYEE_ID, ASSESSOR_EMPLOYEE_ID', 'length', 'max'=>15),
			array('TIME_CREATED, TIME_UPDATED', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ASSMNT_MBR_ID, EMPLOYEE_ID, ASSESSOR_EMPLOYEE_ID, ASSESSMENT_TYPE, ASSESSMENT_ID, JOB_TITLE_ID, USER_CREATED, TIME_CREATED, USER_UPDATED, TIME_UPDATED', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'competencyContents' => array(self::MANY_MANY, 'CompetencyContent', 'asessment_result(ASSMNT_MBR_ID, COMP_CONTENT_ID)'),
			'aSSESSMENT' => array(self::BELONGS_TO, 'Assessment', 'ASSESSMENT_ID'),
			'eMPLOYEE' => array(self::BELONGS_TO, 'Employee', 'EMPLOYEE_ID'),
			'aSSESSOREMPLOYEE' => array(self::BELONGS_TO, 'Employee', 'ASSESSOR_EMPLOYEE_ID'),
			'jOBTITLE' => array(self::BELONGS_TO, 'JobTitle', 'JOB_TITLE_ID'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ASSMNT_MBR_ID' => 'Assmnt Mbr',
			'EMPLOYEE_ID' => 'Employee',
			'ASSESSOR_EMPLOYEE_ID' => 'Assessor Employee',
			'ASSESSMENT_TYPE' => 'Assessment Type',
			'ASSESSMENT_ID' => 'Assessment',
			'JOB_TITLE_ID' => 'Job Title',
			'USER_CREATED' => 'User Created',
			'TIME_CREATED' => 'Time Created',
			'USER_UPDATED' => 'User Updated',
			'TIME_UPDATED' => 'Time Updated',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ASSMNT_MBR_ID',$this->ASSMNT_MBR_ID);
		$criteria->compare('EMPLOYEE_ID',$this->EMPLOYEE_ID,true);
		$criteria->compare('ASSESSOR_EMPLOYEE_ID',$this->ASSESSOR_EMPLOYEE_ID,true);
		$criteria->compare('ASSESSMENT_TYPE',$this->ASSESSMENT_TYPE);
		$criteria->compare('ASSESSMENT_ID',$this->ASSESSMENT_ID);
		$criteria->compare('JOB_TITLE_ID',$this->JOB_TITLE_ID);
		$criteria->compare('USER_CREATED',$this->USER_CREATED);
		$criteria->compare('TIME_CREATED',$this->TIME_CREATED,true);
		$criteria->compare('USER_UPDATED',$this->USER_UPDATED);
		$criteria->compare('TIME_UPDATED',$this->TIME_UPDATED,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}